<template>
  <div class="good-item">
    <good-item-nav-bar></good-item-nav-bar>
    <good-item-info :goodsiteminfo="goodsiteminfo"></good-item-info>
    <good-item-tab-bar></good-item-tab-bar>
  </div>
</template>

<script>
import GoodItemInfo from "./children/GoodItemInfo.vue";
import GoodItemNavBar from "./children/GoodItemNavBar.vue";
import GoodItemTabBar from "./children/GoodItemTabBar.vue";

// 请求数据接口
import { getDetail } from "@/network/detail.js";

export default {
  name: "gooditem",
  components: {
    GoodItemTabBar,
    GoodItemInfo,
    GoodItemNavBar,
  },
  data() {
    return {
      goodsiteminfo: [{}],
    };
  },
  created() {
    //获取商品详情信息
    this.getGoodsInfo();
  },
  mounted() {},
  methods: {
    // 根据商品编码请求商品的详细信息
    getGoodsInfo() {
      let itemid = this.$route.query.item;
      getDetail(itemid).then((result) => {
        console.log(itemid, result);
        this.goodsiteminfo = result;
      });
    },
  },
};
</script>

<style scoped>
.good-item {
  position: relative;
  width: 100%;
}
</style>